package xj.toolkit.netty.transport.endpoint;

import io.netty.channel.Channel;

public abstract class  DefaultEndpointFactory<I> implements EndpointFactory<I> {

	public ServerEndpoint<I> createEndpoint(Channel channel) {
		ServerEndpoint<I> endpoint = createEndpoint();
		endpoint.setChannel(channel);
		endpoint.start();
		return endpoint;
	}

	public void endpointReleased(Endpoint<I> endPoint) {
		// Nothing todo.
	}

	public void stop() {
	}

	public void send(I bean) {
		throw new RuntimeException("Unsupport Operation for send.");
	}

	public int getPendingCount() {
		throw new RuntimeException("Unsupport Operation for send.");
	}

	protected abstract ServerEndpoint<I> createEndpoint();
}
